package com.itheima.stock.config;

import com.google.common.util.concurrent.RateLimiter;
import com.itheima.stock.properties.LimiterProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author zxh
 * @created 2024/11/1 16:35
 * @description 流量控制器
 */
@Configuration
@SuppressWarnings("all")
public class RateLimiterConfiguration {

    @Bean
    public RateLimiter rateLimiter(LimiterProperties limiterProperties){

        return RateLimiter.create(limiterProperties.getConcurrentNum());
    }
}
